package com.ljpz.manage.controller.api;

import com.ljpz.manage.pojo.Item;
import com.ljpz.manage.pojo.ItemDesc;
import com.ljpz.manage.service.ItemDescService;
import com.ljpz.manage.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 商品页面信息查询接口
 * Created by liujunchen on 2016/12/18.
 */
@RequestMapping("api/item")
@Controller
public class ApiItemController {
    @Autowired
    private ItemService itemService  ;
    @RequestMapping(value = "{itemId}" ,method = RequestMethod.GET)
    public ResponseEntity<Item>queryById(@PathVariable("itemId")Long itemId ){
        try {
            Item  item = this.itemService.queryById(itemId) ;
            if(null ==item)
                return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
            return  ResponseEntity.ok(item)  ;
        } catch (Exception e) {
            e.printStackTrace();
        }
         return  ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null) ;
    }
}
